**************************************************
* OIL, ISLAM, and WOMEN Longitudinal Code
*
* Paul Musgrave and Yu-Ming Liou
* musgrave@umass.edu and yl254@georgetown.edu
* 
* Created 28 February 2016
*
**************************************************

**************************************************
* Stata Housekeeping
**************************************************

clear all
capture log close
set more off

set mem 300m
set maxvar 10000

version 11.1

*  Change to your valid directory path
cd "/Users/paulmusgrave/Dropbox/0001 Academic Projects/Ongoing/0127 Oil Islam Women/ISQ Accepted Submission/Replication/Data"


use ISQFINALRossTSData.dta



* * * * * * * * * * * * * * * * * * * * * * * * * 
* CLEAN DATA
* * * * * * * * * * * * * * * * * * * * * * * * * 

lab var FDlogGDP_cap2000_sup_1 "Log GDP per cap"
lab var FDlogGDP_cap2000_supSQ_1 "Log-Square GDP per cap"
lab var FDage_1 "Working Age Share"
lab var FDoil_gas_valuePOPred_1 "Oil Income"

**************************************************
* MODEL DEFINITIONS
**************************************************

local rossmodel FDlogGDP_cap2000_sup_1 FDlogGDP_cap2000_supSQ_1 FDage_1
local rossmodel2 FDlogGDP_cap2000_sup_1 FDage_1


**************************************************
* BEGIN DATA ANALYSIS
**************************************************

cd "../Drafts/Tables"
tsset iso year

* * * * * * * * * * * * * * * * * * * * * * * * 
* Table: tab:rossera
* * * * * * * * * * * * * * * * * * * * * * * * 

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1, fe
eststo rosserabase

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 if year<=1979, fe
eststo rosseraearly

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 if year>1979, fe
eststo rosseralate

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 if year<=1973, fe
eststo rosseracol4

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 if year>=1974 & year<=1986, fe
eststo rosseracol5

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 if year>1986, fe 
eststo rosseracol6


esttab rosserabase rosseraearly rosseralate rosseracol4 rosseracol5 rosseracol6 ///
using ISQFINALMainBodyTable02.tex, replace booktabs ///
 p label compress ///
title("Comparing Periodizations of Models of Oil and FLFP" \label{tab:rossera}) ///
mtitles("Base" "Pre-1979" "Post 1979" "Pre-1973" "1973--86" "Post-1986") ///
addnotes("Columns 1, 2, and 3 replicate Ross's work. Columns 4--6 present our alternative periodization," "delimited before, during, and after the high oil price period. Models are first-differenced OLS.") 
*substitute({table} {sidewaystable})




* * * * * * * * * * * * * * * * * * * * * * * * 
* Table: tab:heteffects
* * * * * * * * * * * * * * * * * * * * * * * * 
sort cty year

bysort cty: gen cheibub65 = chga_demo if year == 1965
bysort cty: carryforward cheibub65, replace

bysort cty: gen cheibub73 = chga_demo if year == 1973
bysort cty: carryforward cheibub73, replace


bysort cty: gen polity65 = p_polity2 if year == 1965
bysort cty: carryforward polity65, replace

bysort cty: gen polity73 = p_polity2 if year == 1973
bysort cty: carryforward polity73, replace

* Autocracies defined using Cheibub

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 ///
if cheibub65 == 0, fe
eststo cheibubautoc65

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 ///
if cheibub73 == 0, fe
eststo cheibubautoc73

* Democracies defined using Cheibub
xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 ///
if cheibub65 == 1, fe
eststo cheibubdemoc65

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 ///
if cheibub73 == 1, fe
eststo cheibubdemoc73

* Defined using Polity
xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 ///
if polity73 >= 7& polity73<=10, fe
eststo polity73democ

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 ///
if polity73 <=-7 & polity73>=-10, fe
eststo polity73autoc

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 ///
if polity65 >= 7 & polity65<=10, fe
eststo polity65democ

xtregar FDlaborfemale `rossmodel2' FDoil_gas_valuePOPred_1 ///
if polity65 <=-7 & polity65>=-10, fe
eststo polity65autoc


esttab polity65autoc polity73autoc polity65democ polity73democ  ///
cheibubautoc73  cheibubautoc65  cheibubdemoc65 cheibubdemoc73 ///
using ISQFINALMainBodyTable03.tex, ///
title("Heterogenous Effects in the Ross Model" \label{tab:heteffects}) ///
 replace p label compress ///
 mtitles("Autoc '65" "Autoc '73" "Democ '65" "Democ '73" "Autoc '65" "Autoc '73" "Democ '65" "Democ '73") ///
 addnotes("Models are stratified by whether the countries were autocratic or democratic in 1965 or 1973." ///
 "Columns 1-4 use Polity measure; columns 5-8 use Cheibub, Gandhi and Vreeland (2010) measures.") ///
substitute({table} {sidewaystable})


